/**
 * 
 */
package com.xteam.purview.base;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoader;

/**
 * 工具类
 * 
 * @author tangkf
 */
public class AppContextUtils {
	
	private static ApplicationContext applicationContext;
	
	static{
		AppContextUtils.setApplication(ContextLoader.getCurrentWebApplicationContext());
	}
	
	private AppContextUtils() {
		
	}
	
	public static void setApplicationContext(ApplicationContext ac){
		applicationContext	= ac;
	}

	public static ApplicationContext getContext() {
		return applicationContext;
	}

	public static Object getBean(String name) {
		return AppContextUtils.applicationContext.getBean(name);
	}

	static void setApplication(ApplicationContext applicationContext) {
		AppContextUtils.applicationContext = applicationContext;
	}

	public static void clear() {
		AppContextUtils.applicationContext = null;
	}
}